package com.tsp.ssm.controller;

import com.tsp.ssm.po.ItemsCustom;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by 隼 on 2016/12/4.
 * json交互测试
 */
@Controller
@RequestMapping( value = "/json" )
public class jsonTest {

    //jason 测试
    @RequestMapping(value ="/jsonTest", method ={RequestMethod.GET,RequestMethod.POST} )
    public  String jsonTest(){
        return "jsonTest";
    }

    //请求json串(商品信息)，输出json(商品信息)
    //@RequestBody将请求的商品信息的json串转成itemsCustom对象
    //@ResponseBody将itemsCustom转成json输出
    @RequestMapping(value ="/requestJson", method ={RequestMethod.POST},consumes = "application/json")
    public @ResponseBody
    ItemsCustom requestJson(@RequestBody  ItemsCustom itemsCustom){

        //@ResponseBody将itemsCustom转成json输出
        return itemsCustom;
    }

    //请求key/value，输出json
    @RequestMapping("/responseJson")
    public @ResponseBody ItemsCustom responseJson(ItemsCustom itemsCustom){

        //@ResponseBody将itemsCustom转成json输出
        return itemsCustom;
    }
}
